home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / programming / colpectius1 / bouncing_ball.amos / bouncing_ball.amosSourceCode < prev    next >
AMOS Source Code  |  1995-09-07  |  2KB  |  79 lines

  1. ' Bouncing ball
  2. ' ~~~~~~~~~~~~~
  3. ' by Ben Wyatt, bwyatt@paston.co.uk
  4.  
  5. ' A reasonably accurate bouncing ball
  6. ' It doesn't roll down hills or anything (yet) 
  7. ' If the ball gets stuck, press the lmb, to er... shake the screen 
  8. ' It's just a test to see if a pinball game would be possible and collisions 
  9. ' would be fast enough :) but for some reason, it's fun to watch :-/ 
  10. ' Turbo/AMCAF users can replace the Point/Sqr functions with the faster
  11. ' equivilants, not that it makes any difference, it's fixed to 1/50 speed
  12. ' Remove the Wait Vbl and compile it for super sonic speed :-) 
  13.  
  14. Degree 
  15.  
  16. Dim SAN(15),CAN(15)
  17.  
  18. ' Precalc some stuff 
  19. For N=0 To 15
  20.    SAN(N)=Sin(N*(360/16))*8 : CAN(N)=Cos(N*(360/16))*8
  21. Next N
  22.  
  23. Load "Ball.Abk"
  24. Load Iff Fsel$("Ball_Scr_*","","Select one of the shown files",""),0
  25. Screen Display 0,128,37,320,256
  26. YS=0
  27. Hide On 
  28.  
  29. Hot Spot 1,7,7
  30.  
  31. Do 
  32.    
  33.    Screen Offset 0,0,0
  34.    
  35.    ' Get a position to start in 
  36.    Repeat 
  37.       X=X Mouse : Y=Y Mouse
  38.       Sprite 0,X,Y,1
  39.    Until Mouse Key>0
  40.    
  41.    X=X Screen(X)*1024 : Y=Y Screen(Y)*1024
  42.    XSP=0 : YSP=0 : ROT=0
  43.    
  44.    Repeat 
  45.       
  46.       Add X,XSP
  47.       Add Y,YSP
  48.       Add YSP,100
  49.       
  50.       XSD=XSP : YSD=YSP
  51.       For N=0 To 15
  52.          FP=Point(X/1024+SAN(N),Y/1024+CAN(N))
  53.          If FP>CP
  54.             SPD=Sqr(XSD*XSD+YSD*YSD)/16
  55.             AN=N+8
  56.             If AN>15 : Add AN,-16 : End If 
  57.             XSP=SAN(AN)*SPD : YSP=CAN(AN)*SPD
  58.             Add X,XSP : Add Y,YSP
  59.             ' If you want to get really annoyed, unrem the next line :-) 
  60.             'Boom    
  61.          End If 
  62.       Next N
  63.       
  64.       Sprite 0,X Hard(X/1024),Y Hard(Y/1024)-YS,1
  65.       YS=Min(Max(Y/1024-128,0),Screen Height-256)
  66.       Screen Offset 0,0,YS
  67.  
  68.       If Mouse Key=1 and XSP/100=0 and YSP/100=0
  69.          If Point(X/1024,Y/1024+9)>0
  70.             Add XSP,Rnd(4)*256-512 : Add YSP,-Rnd(2)*512-512
  71.             Screen Offset 0,0,YS+3+Rnd(3)
  72.          End If 
  73.       End If 
  74.  
  75.       Wait Vbl 
  76.       
  77.    Until Y/1024>Screen Height
  78.    
  79. Loop